package com.memorypalace.action;

import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.memorypalace.pojo.CardStyle;
import com.memorypalace.study.biz.ICardStyleBiz;
import com.memorypalace.util.AJaxUtil;

@Controller
@RequestMapping("/cardstyle")
public class CardStyleAction {

	@Autowired
	private ICardStyleBiz cardStyleBiz;

	// 新增卡片风格
	@RequestMapping("/addCardStyle")
	@ResponseBody
	public void addCardStyle(CardStyle cardStyle, HttpServletResponse response) {
		cardStyleBiz.addCardStyle(cardStyle);
		String cardStyleId = cardStyle.getCardStyleId();

		AJaxUtil.sendJsonByString(cardStyleId, response);

	}

	// 修改卡片风格
	@RequestMapping("/updateCardStyle")
	public void updateCardStyle(CardStyle cardStyle, Map<String, Object> map) {
		Boolean updateFlag = cardStyleBiz.updateCardStyle(cardStyle);
		map.put("updateFlag", updateFlag);
	}
	// 删除卡片风格

	@RequestMapping("/deleteCardStyle")
	@ResponseBody
	public void deleteCardStyle(String cardStyleId, HttpServletResponse response) {
		Boolean deleteFlag = cardStyleBiz.deleteCardStyle(cardStyleId);
		System.out.println("删除卡片样式:"+deleteFlag);
		AJaxUtil.sendJsonByObj(deleteFlag, response);
	}

}
